$(function () {
    var payment_dialog, payment_form, paymentHandle_datagrid, payment_check_dialog,payment_check_form;
    paymentHandle_datagrid = $("#paymentHandle_datagrid");
    payment_check_form = $("#payment_check_form");
    payment_dialog = $("#payment_dialog");
    payment_check_dialog = $("#payment_check_dialog");
    payment_form = $("#payment_form");
    //缴费窗口
    payment_dialog.dialog({
        title: '\&emsp;缴费',
        closable: true,
        minimizable: true,
        collapsible: true,
        width: 700,
        height: 400,
        closed: true,
        modal: true,
        resizable: true,
        buttons: "#payment_btn",
        top:150,
        left:450
    });
    //
    //查看缴费信息窗口
    payment_check_dialog.dialog({
        title: '\&emsp;缴费信息',
        closable: true,
        minimizable: true,
        collapsible: true,
        width: 700,
        height: 400,
        closed: true,
        modal: true,
        resizable: true,
        buttons: "#payment_check_btn",
        onOpen:function () {
            $("#payment_check_form :input").prop("readonly",true);
        }
    });
    //
    //统一管理点击事件
    $("a[data-paycmd]").on("click", function () {
        var payCmd = $(this).data("paycmd");
        if (payCmd) {
            payCmdObj[payCmd]();
        }
    });
    var orderBillId = $("[name='orderBill.id']").val();//获取到paymentHandle.jsp里面的orderBillId

    //===============================================================================
    //统一处理点击事件
    var payCmdObj = {
        //确认缴费
        payConfirm: function () {
            console.log(orderBillId)
            $.messager.confirm("温馨提示", "核对无误,确认缴费吗?", function (yes) {
                if (yes) {
                   /* $.("#payment_form").form("sumbit",{
                        url:'/paymentConfirm/confirm'
                    })*/
                    /*$.get("/paymentConfirm/confirm?orderBillId=" + orderBillId, function (data) {
                        if (data.success) {
                            $.messager.alert("温馨提示", data.msg, "info",function () {
                                paymentHandle_datagrid.datagrid("reload");
                                payment_dialog.dialog("close");
                            });
                        } else {
                            $.messager.alert("温馨提示", data.msg, "error");
                        }
                    }, "json")*/
                }
            });
        },
        //缴费返回功能
        back: function () {
            payment_dialog.dialog("close");
        },
        //查看返回
        check_back: function () {
            payment_check_dialog.dialog("close");
        }
    }
    //
});
function payconfirm(){
    $("#payment_form").form("submit",{
        url:'/paymentConfirm/confirm',
        success:function(data){
            data = $.parseJSON(data);
            if (data.success){
                $.messager.alert("温馨提示", data.msg, "info",function () {
                    $("#paymentHandle_datagrid").datagrid("reload");
                    $("#payment_dialog").dialog("close");
                });
            }else {
                $.messager.alert("温馨提示",data.msg,"error")
            }
        }
    })
}


